package it.globalgamejam.dsm.menu 
{
	import flash.utils.Timer;
	import it.globalgamejam.scar.game.GameWorld;
	import net.flashpunk.Entity;
	import net.flashpunk.FP;
	import net.flashpunk.graphics.Image;
	import net.flashpunk.tweens.misc.VarTween;
	import net.flashpunk.World;	
	
	/**
	 * ...
	 * @author self
	 */
	public class IntroWorld extends World
	{
		var card_time:Number = 0;
		var balla:Number = new Number(0);
		var a:Array = [];
		var c1:cards;
		var c2:cards;
		var c3:cards;
		var c4:cards;
		var c5:cards;
		var c6:cards;
		var c7:cards;
		var c8:cards;
		var c9:cards;
		var c10:cards;
		var c11:cards;
		var c12:cards;
		var c13:cards;
		var myTimer:Timer = new Timer(0, 20)
			
		override public function update():void 
		{
			
			trace(card_time);
			
			balla += myTimer.currentCount;
			
			if (balla > 2000)
			{
				if (card_time == 0) 
				{
				card_time += 1;
				}
			}
			
			switch (card_time)
				{
					case 1:
						if ( balla > 3000)
						{
							c1.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, 0, 0);
							balla = 0;
							card_time += 1;
						}
							break;
						
					case 2:
						if ( balla > 3500)
						{
							c2.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, 5, 0);
							balla = 0;
							card_time += 1;
						}
							break;

					case 3:
						if ( balla > 3000)
						{
							c3.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, -5, 0);
							balla = 0;
							card_time += 1;
						}
							break;
						
					case 4:
						if ( balla > 4250)
						{
							c4.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, 5, 0);
							balla = 0;
							card_time += 1;
						}
							break;
						
					case 5:
						if ( balla > 4250)
						{
							c5.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, -5, 0);
							balla = 0;
							card_time += 1;
						}
							break;
						
					case 6:
						if ( balla > 4250)
						{
							c6.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, 10, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
					
					case 7:
						if ( balla > 4250)
						{
							c7.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, -10, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
					
					case 8:
						if ( balla > 2200)
						{
							c8.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, 15, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 9:
						if ( balla > 1800)
						{
							c9.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, -15, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
					
					case 10:
						if ( balla > 1800)
						{
							c9.moveTween(1000,1000, 20, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 11:
						if ( balla > 250)
						{
							c8.moveTween(-1000,-1000, -20, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 12:
						if ( balla > 250)
						{
							c7.moveTween(1000,1000, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 13:
						if ( balla > 250)
						{
							c6.moveTween(-1000,-1000, 0, 0);
							balla = 0;
							card_time += 1;
						}
							break;
						
					case 14:
						if ( balla > 250)
						{
							c5.moveTween(1000,1000, 5, 0);
							balla = 0;
							card_time += 1;
						}
							break;
						
					case 15:
						if ( balla > 250)
						{
							c4.moveTween(-1000,-1000, -5, 0);
							balla = 0;
							card_time += 1;
						}
							break;
						
					case 16:
						if ( balla > 250)
						{
							c3.moveTween(1000,1000, 10, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 17:
						if ( balla > 250)
						{
							c2.moveTween(-1000,-1000, -5, 0);
							balla = 0;
							card_time += 1;
						}
							break;
						
					case 18:
						if ( balla > 250)
						{
							c1.moveTween(1000,1000, 10, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 19:
						if ( balla > 1200)
						{
							c9.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, 0, 0);
							balla = 0;
							card_time += 1;
						}
							break;
						
					case 20:
						if ( balla > 1350)
						{
							c10.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, 5, 0);
							balla = 0;
							card_time += 1;
						}
							break;
						
					case 21:
						if ( balla > 1350)
						{
							c11.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, -5, 0);
							balla = 0;
							card_time += 1;
						}
							break;
						
					case 22:
						if ( balla > 1350)
						{
							c12.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, 10, 0);
							balla = 0;
							card_time += 1;
						}
							break;
							
					case 23:
						if ( balla > 1350)
						{
							c13 = new cards(FP.width / 2 - 150 , FP.height / 2 - 150, 13, this);
							add(c13);
							card_time += 1;
						}
							break;
					
					case 24:
						if ( balla > 500)
						{
							c13.moveTween(FP.width / 2 - 100 , FP.height / 2 - 200, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 25:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 - 50 , FP.height / 2  - 250, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
				
					case 26:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 , FP.height / 2 - 200, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 27:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 + 50 , FP.height / 2 - 150, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 28:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 , FP.height / 2 - 100, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 29:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 - 50 , FP.height / 2 - 50, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 30:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 - 100 , FP.height / 2 - 100, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 31:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 32:
						if ( balla > 500)
						{
							c13.moveTween(FP.width / 2 - 100 , FP.height / 2 - 200, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 33:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 - 50 , FP.height / 2  - 250, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
				
					case 34:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 , FP.height / 2 - 200, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 35:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 + 50 , FP.height / 2 - 150, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 36:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 , FP.height / 2 - 100, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 37:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 - 50 , FP.height / 2 - 50, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 38:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 - 100 , FP.height / 2 - 100, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 39:
						if ( balla > 125)
						{
							c13.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, 0, 0);
							balla = 0;
							this.card_time += 1;
						}
							break;
							
					case 40:
						if ( balla > 1500)
						{
							c13.moveTween(FP.width / 2 - 150 , FP.height / 2 - 150, 0, 0);
							balla = 0;
							this.card_time += 1;
							FP.world = new GameWorld(GameWorld.levels[GameWorld.currentLevel = 3]);
						}
							break;		
				}		
		}
		
		public function IntroWorld() 
		{
			var bg:Entity = new background(0, 0);
			Image(bg.graphic).scaledHeight = 800;
			Image(bg.graphic).scaledWidth = 800;
			add(bg);
			
			balla = new Number(0);

			c1 = new cards(900, 900, 1, this);
			add(c1);
			
			c2 = new cards(-100, 800, 2, this);	
			add(c2);
			
			c3 = new cards(900, 900, 3, this);
			add(c3);
			
			c4 = new cards(-100, 800, 4, this);	
			add(c4);
			
			c5 = new cards(-900, -900, 5, this);
			add(c5);
			
			c6 = new cards(900, 900, 6, this);
			add(c6);
			
			c7 = new cards(-100, 800, 7, this);	
			add(c7);
			
			c8 = new cards(-900, -900, 8, this);
			add(c8);
			
			c9 = new cards(900, 900, 9, this);
			add(c9);
			
			c10 = new cards(-100, 800, 10, this);	
			add(c10);
			
			c11 = new cards(-900, -900, 11, this);
			add(c11);
			
			c12 = new cards(900, 900, 12, this);
			add(c12);

			
			myTimer.start();
			balla = myTimer.currentCount;
			this.update();
		}
		
	}

}